package cate.game.activity.specall.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.specall.SpeCallActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBSpeCall;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "独立卡池召唤-兑换 请求")
@OperationSetter(value = GDOperation.SPE_EXCHANGE, sub = "tid")
public class SpeCallExchageReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField("商品tid")
    public int tid;
    @NoteField("数量")
    public int num;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        SpeCallActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<SpeCallActivity> result = single.exchange(tid, num);
        if (result.ok()) {
            result.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), result.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBSpeCall.EXCHANGE_REQ;
    }
}
